﻿using System;

namespace KWBridge
{
    public partial class ParasForm1 : ParasForm
    {
        public ParasForm1( )
        {
            InitializeComponent( );

            InitButtonsClick( );
        }

        private void InitButtonsClick( )
        {
            btnAuthoring.Click += new EventHandler( btnAuthoring_Click );
            btnClose.Click += new EventHandler( btnClose_Click );
            btnSave.Click += new EventHandler( btnSave_Click );
            btnAlarmParas.Click += new EventHandler( btnAlarmParas_Click );
        }

        internal override void InitData( )
        {
            dic_ComboBox.Add( "风机" , kjParasUserControl1.cbb风机 );
            dic_ComboBox.Add( "风门" , kjParasUserControl1.cbb风门 );
            dic_ComboBox.Add( "烟雾" , kjParasUserControl1.cbb烟雾 );
            dic_ComboBox.Add( "风筒" , kjParasUserControl1.cbb风筒 );
            dic_ComboBox.Add( "开停" , kjParasUserControl1.cbb开停 );
            dic_ComboBox.Add( "开关" , kjParasUserControl1.cbb开关 );
            dic_ComboBox.Add( "断电" , kjParasUserControl1.cbb断电 );
            dic_ComboBox.Add( "馈电" , kjParasUserControl1.cbb馈电 );
            dic_ComboBox.Add( "闭锁" , kjParasUserControl1.cbb闭锁 );
            dic_ComboBox.Add( "控制" , kjParasUserControl1.cbb控制 );
            dic_ComboBox.Add( "分站" , kjParasUserControl1.cbb分站 );
            dic_ComboBox.Add( "供电" , kjParasUserControl1.cbb供电 );

            dic_StatesCheckBox.Add( "超上限" , kjParasUserControl1.cb超上限 );
            dic_StatesCheckBox.Add( "超下限" , kjParasUserControl1.cb超下限 );
            dic_StatesCheckBox.Add( "超断电" , kjParasUserControl1.cb超断电 );
            dic_StatesCheckBox.Add( "调校" , kjParasUserControl1.cb调校 );
            dic_StatesCheckBox.Add( "超量程" , kjParasUserControl1.cb超量程 );
            dic_StatesCheckBox.Add( "负漂" , kjParasUserControl1.cb负漂 );
            dic_StatesCheckBox.Add( "断线" , kjParasUserControl1.cb断线 );
            dic_StatesCheckBox.Add( "通信中断" , kjParasUserControl1.cb通信中断 );
            dic_StatesCheckBox.Add( "故障" , kjParasUserControl1.cb故障 );
            dic_StatesCheckBox.Add( "未知" , kjParasUserControl1.cb未知 );

            dic_TypesCheckBox.Add( "甲烷" , kjParasUserControl1.cb甲烷 );
            dic_TypesCheckBox.Add( "一氧化碳" , kjParasUserControl1.cb一氧化碳 );
            dic_TypesCheckBox.Add( "风速" , kjParasUserControl1.cb风速 );
            dic_TypesCheckBox.Add( "温度" , kjParasUserControl1.cb温度 );
            dic_TypesCheckBox.Add( "压力" , kjParasUserControl1.cb压力 );
            dic_TypesCheckBox.Add( "全部模" , kjParasUserControl1.cb全部模 );

            dic_TypesCheckBox.Add( "主扇" , kjParasUserControl1.cb主扇 );
            dic_TypesCheckBox.Add( "局扇" , kjParasUserControl1.cb局扇 );
            dic_TypesCheckBox.Add( "风机" , kjParasUserControl1.cb局扇 );
            dic_TypesCheckBox.Add( "断电" , kjParasUserControl1.cb断电 );

            //dic_TypesCheckBox.Add("断电器", kjParasUserControl1.cb断电);
            dic_TypesCheckBox.Add( "烟雾" , kjParasUserControl1.cb烟雾 );
            dic_TypesCheckBox.Add( "风门" , kjParasUserControl1.cb风门 );
            dic_TypesCheckBox.Add( "全部开" , kjParasUserControl1.cb全部开 );
        }

        /// <summary>
        /// 从主程序获取参数
        /// </summary>
        internal override void ConvertParasFrom( )
        {
            base.ConvertParasFrom( );

            tbCoalMineName.Text = cfg.Name;// mainForm.CoalMineName;
            tbCoalMineId.Text = cfg.Id.ToString( );// mainForm.CoalMineId.ToString();
            tbInterval.Text = cfg.Interval.ToString( );// mainForm.Interval.ToString();
            tbIPAddress.Text = cfg.IPAddr;// mainForm.ServerIp;
            tbBreakInterval.Text = cfg.BreakInterval.ToString( );// n.ToString();

            kjParasUserControl1.tbPath.Text = cfg.KJSysParas.KJPath;// mainForm.Path;
            kjParasUserControl1.tbDevFile.Text = cfg.KJSysParas.DevFile;// mainForm.DevFileName;
            kjParasUserControl1.tbRtData.Text = cfg.KJSysParas.RtDataFile;// mainForm.RtDataName;
            kjParasUserControl1.cbbKJType.Text = cfg.KJSysParas.KJType;// mainForm.KJType;
        }

        /// <summary>
        /// 把参数转换到主程序
        /// </summary>
        internal override void ConvertParasTo( )
        {
            base.ConvertParasTo( );

            //mainForm.kjSysUserControl.tbCoalMineName.Text = tbCoalMineName.Text;
            //mainForm.kjSysUserControl.tbInterval.Text = tbInterval.Text;
            //mainForm.kjSysUserControl.tbIPAddress.Text = tbIPAddress.Text;
            //mainForm.kjSysUserControl.tbPath.Text = kjParasUserControl1.tbPath.Text;
            //mainForm.kjSysUserControl.tbDevFile.Text = kjParasUserControl1.tbDevFile.Text;
            //mainForm.kjSysUserControl.tbRtData.Text = kjParasUserControl1.tbRtData.Text;
            //mainForm.kjSysUserControl.tbKJType.Text = kjParasUserControl1.cbbKJType.Text;
            //mainForm.CoalMineName = tbCoalMineName.Text;
            //uint nId = mainForm.CoalMineId;
            //uint.TryParse(tbCoalMineId.Text, out nId);
            //mainForm.CoalMineId = nId;
            //int n = 10;
            //if (int.TryParse(tbInterval.Text, out n))
            //{
            //    mainForm.Interval = n;
            //}

            //if (int.TryParse(tbBreakInterval.Text, out n))
            //{
            //    mainForm.nBreakInterval = n;
            //}
            //if (mainForm.nBreakInterval >= 10)
            //{
            //    mainForm.nBreakInterval = 10;
            //}
            //mainForm.ServerIp = tbIPAddress.Text;
            //mainForm.Path = kjParasUserControl1.tbPath.Text;
            //mainForm.DevFileName = kjParasUserControl1.tbDevFile.Text;
            //mainForm.RtDataName = kjParasUserControl1.tbRtData.Text;
            //mainForm.KJType = kjParasUserControl1.cbbKJType.Text;
            //foreach (string type in mainForm.DigitalTypes)
            //{
            //    GetDigitalState(type);
            //}

            //SetAlarmOptions();

            //mainForm.UpdateParas1();
        }
    }
}